#!/usr/bin/env python3
"""
fasta_to_tsv.py
用法: python fasta_to_tsv.py input.fasta output.tsv
"""
import sys

def fasta_to_tsv(infile, outfile):
	with open(infile, 'r') as fin, open(outfile, 'w') as fout:
		seq_id = None
		seq_lines = []
		for line in fin:
			line = line.strip()
			ifnot line:
				continue
			if line.startswith('>'):
				if seq_id isnotNone:
					fout.write(f"{seq_id}\t{''.join(seq_lines)}\n")
				seq_id = line[1:]
				seq_lines = []
			else:
				seq_lines.append(line)
		if seq_id isnotNone:
			fout.write(f"{seq_id}\t{''.join(seq_lines)}\n")

if __name__ == "__main__":
	if len(sys.argv) != 3:
		print("用法: python fasta_to_tsv.py input.fasta output.tsv")
		sys.exit(1)
	fasta_to_tsv(sys.argv[1], sys.argv[2])